package poker;

import java.awt.Color;
import java.io.*;
import java.awt.*;
import java.awt.EventQueue;
import javax.swing.*;

public class HandGui extends JLabel {
	private static final long serialVersionUID = 1L;
	
	CardGui Cards[] = new CardGui[5];
	public HandGui(Hand hand)	{
		setBackground(new Color(0, 139, 139));
		setFocusable(false);
		setLayout(null);
		setBounds(0, 0, 240, 90);

		int j;	
		for (j = 0 ; j < 5; j++){
			Cards[j] = new CardGui(hand.cards[j].getSuit(),hand.cards[j].getRank());
			Cards[j].setBackground(new Color(0, 128, 128));
			Cards[j].setBounds(0+48*j, 0, 48, 64);
			add(Cards[j]);
		}
	}
		void showHand(boolean show){
			if (show)
				for (int j = 0 ; j < 5; j++){
					Cards[j].showCard(true);
				}
			else
					for (int j = 0 ; j < 5; j++){
						Cards[j].showCard(false);
					}
		}
	  void exchange(Deck deck, Hand hand,  int[] cardsToExchange){
		  hand.exchange(deck, cardsToExchange);
		  if(cardsToExchange[0]!=0){
		      for(int i=0;i<(cardsToExchange.length);i++){
			    remove(Cards[cardsToExchange[i]-1]);
		    	 Cards[cardsToExchange[i]-1] = new CardGui(hand.cards[cardsToExchange[i]-1].getSuit(),hand.cards[cardsToExchange[i]-1].getRank());
		    	 Cards[cardsToExchange[i]-1].setBounds(0+48*(cardsToExchange[i]-1), 0, 48, 64);
			    add(Cards[cardsToExchange[i]-1]);
			    repaint();
			  }
			}
		  
	  }
}